/*
 * And.java
 * 
 * Created on Jun 4, 2007, 10:42:12 PM
 * 
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.infomancers.collections.predicates;

import com.infomancers.collections.Predicate;
import java.util.Arrays;
import java.util.Collection;

/**
 *
 * @author aviadbd
 */
public class And<T> implements Predicate<T> {
    private Collection<Predicate<T>> predicates;
    
    
    public And(Predicate<T>... predicates)  {
        this(Arrays.asList(predicates));
    }
            
    public And(Collection<Predicate<T>> predicates) {
        this.predicates = predicates;
    }
    
    public boolean isTrue(T item) {
        for (Predicate<T> p : predicates) {
            if (!p.isTrue(item)) {
                return false;
            }
        }
        
        return true;
    }

}
